package edu.sctu.xiangkun.day201506.day20150615.texttwo;

import java.io.*;

/**
 * Created by user04 on 2015/6/15.
 */
public class FileLineReadOrWriteDemo {
    public void getLineContent(File file) throws IOException {
        try{
            File file1 = new File("D://11.txt");
            FileReader fileReader = new FileReader(file);
            BufferedReader bufferReader = new BufferedReader(fileReader);
            FileWriter fileWriter = new FileWriter(file1);
            BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
            try{
              while(bufferReader.ready()) {
                String str = bufferReader.readLine();
                System.out.println("每行的内容 : " + str);
                bufferedWriter.write(str);
                bufferedWriter.newLine();
              }
            }catch(IOException e){
                 e.printStackTrace();
                }

            try{
              bufferReader.close();
                bufferedWriter.close();
            }catch(IOException e){
                e.printStackTrace();
            }

            if(!new File("D://11.txt").exists()) {
                System.out.println("创建失败!");
            }

        }catch(FileNotFoundException e){
            e.printStackTrace();
        }
    }
}
